/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.edinet.agencialinea3.ejb.entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.*;

/**
 *
 * @author ivan
 */
@Entity
@Table(name = "ESTADO_CONTABLE")
@NamedQueries({
    @NamedQuery(name = "EstadoContable.findAll", query = "SELECT e FROM EstadoContable e"),
    @NamedQuery(name = "EstadoContable.findByDebe", query = "SELECT e FROM EstadoContable e WHERE e.debe = :debe"),
    @NamedQuery(name = "EstadoContable.findByHaber", query = "SELECT e FROM EstadoContable e WHERE e.haber = :haber"),
    @NamedQuery(name = "EstadoContable.findBySaldo", query = "SELECT e FROM EstadoContable e WHERE e.saldo = :saldo"),
    @NamedQuery(name = "EstadoContable.findByDeclaracionNumeroDespacho", query = "SELECT e FROM EstadoContable e WHERE e.estadoContablePK.declaracionNumeroDespacho = :declaracionNumeroDespacho"),
    @NamedQuery(name = "EstadoContable.findByDocumentoNumeroDespacho", query = "SELECT e FROM EstadoContable e WHERE e.estadoContablePK.documentoNumeroDespacho = :documentoNumeroDespacho")})
public class EstadoContable implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected EstadoContablePK estadoContablePK;
    @Column(name = "DEBE")
    private BigInteger debe;
    @Column(name = "HABER")
    private BigInteger haber;
    @Column(name = "SALDO")
    private BigInteger saldo;
    @JoinColumn(name = "DOCUMENTO_NUMERO_DESPACHO", referencedColumnName = "NUMERO_DESPACHO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Documento documento;
    @JoinColumn(name = "DECLARACION_NUMERO_DESPACHO", referencedColumnName = "NUMERO_DESPACHO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Declaracion declaracion;

    public EstadoContable() {
    }

    public EstadoContable(EstadoContablePK estadoContablePK) {
        this.estadoContablePK = estadoContablePK;
    }

    public EstadoContable(BigInteger declaracionNumeroDespacho, BigInteger documentoNumeroDespacho) {
        this.estadoContablePK = new EstadoContablePK(declaracionNumeroDespacho, documentoNumeroDespacho);
    }

    public EstadoContablePK getEstadoContablePK() {
        return estadoContablePK;
    }

    public void setEstadoContablePK(EstadoContablePK estadoContablePK) {
        this.estadoContablePK = estadoContablePK;
    }

    public BigInteger getDebe() {
        return debe;
    }

    public void setDebe(BigInteger debe) {
        this.debe = debe;
    }

    public BigInteger getHaber() {
        return haber;
    }

    public void setHaber(BigInteger haber) {
        this.haber = haber;
    }

    public BigInteger getSaldo() {
        return saldo;
    }

    public void setSaldo(BigInteger saldo) {
        this.saldo = saldo;
    }

    public Documento getDocumento() {
        return documento;
    }

    public void setDocumento(Documento documento) {
        this.documento = documento;
    }

    public Declaracion getDeclaracion() {
        return declaracion;
    }

    public void setDeclaracion(Declaracion declaracion) {
        this.declaracion = declaracion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (estadoContablePK != null ? estadoContablePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EstadoContable)) {
            return false;
        }
        EstadoContable other = (EstadoContable) object;
        if ((this.estadoContablePK == null && other.estadoContablePK != null) || (this.estadoContablePK != null && !this.estadoContablePK.equals(other.estadoContablePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.edinet.agencialinea3.ejb.entity.EstadoContable[ estadoContablePK=" + estadoContablePK + " ]";
    }
    
}
